<fieldset>
  <legend>New Relic</legend>
  <% if SamsonNewRelic.enabled? %>
    <% apps = SamsonNewRelic::Api.applications rescue nil %>
    <% if apps %>
      <% form.object.new_relic_applications.build %>

      <p class="col-lg-offset-2">
        Names of New Relic Applications to display during deploy
      </p>
      <%= form.fields_for :new_relic_applications do |app_field| %>
        <div class="form-group">
          <div class="col-lg-6 col-lg-offset-2">
            <%= app_field.select :name, apps.keys.sort, class: "form-control", include_blank: true %>
          </div>

          <%= delete_checkbox app_field %>
        </div>
      <% end %>
    <% else %>
      <div>Error fetching newrelic apps.</div>
    <% end %>
  <% else %>
    <div>Set NEWRELIC_API_KEY to use NewRelic stats (disable the new_relic plugin to hide this warning).</div>
  <% end %>
</fieldset>
